﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Hkwl.WorldExpo.Merchant.Common;
using Hkwl.WorldExpo.Merchant.Model;
using Hkwl.WorldExpo.Merchant.Service;

namespace Hkwl.WorldExpo.Merchant.Web
{
    public partial class Service : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                if (!String.IsNullOrEmpty(Request.QueryString["txtCellPhone"]))
                {
                    string cellPhone = Request.QueryString["txtCellPhone"];
                    int merchantId = 1;
                    if (Session["MerchantId"] != null)
                    {
                        merchantId = int.Parse(Session["MerchantId"].ToString());
                    }

                    int client = ServiceLocator.IClientService.GetNxClientByCellphone(cellPhone.Trim(), merchantId);
                    if (client > 0)
                    {
                        Response.Write("0");
                    }
                    else
                    {
                        Response.Write("1");
                    }
                    Response.End();
                }
                if (!String.IsNullOrEmpty(Request.QueryString["txtProjectName"]))
                {
                    string projectName = Request.QueryString["txtProjectName"];
                    int merchantId = 1;
                    if (Session["MerchantId"] != null)
                    {
                        merchantId = int.Parse(Session["MerchantId"].ToString());
                    }
                    int project = ServiceLocator.IProjectService.GetNxProjectByName(projectName, merchantId);
                    if (project > 0)
                    {
                        Response.Write("0");
                    }
                    else
                    {
                        Response.Write("1");
                    }
                    Response.End();
                }

                if (!String.IsNullOrEmpty(Request.QueryString["txtGroup"]))
                {
                    string groupName = Request.QueryString["txtGroup"];
                    int merchantId = 1;
                    if (Session["MerchantId"] != null)
                    {
                        merchantId = int.Parse(Session["MerchantId"].ToString());
                    }
                    int group = ServiceLocator.IClientService.GetNxGroupCountByName(groupName, merchantId);
                    if (group > 0)
                    {
                        Response.Write("0");
                    }
                    else
                    {
                        Response.Write("1");
                    }
                    Response.End();
                }
            }
        }
    }

